﻿//===============================================================================
// File: SpecialtyManager.cs
// Author:Veiller Hu
// CLR Version：4.0.30319.1
// Created Date:  2011/1/12 7:10:56 PM 
// Summary:  
//===============================================================================
//
// Copyright (c) East China Information Technology Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
// KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
// PURPOSE.
//===============================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GPMS.BLL
{
    using GPMS.Model;
    public class SpecialtyManager
    {
        private ExtendedGPMSDb gpmsDb;
        public SpecialtyManager()
        {
            gpmsDb = new ExtendedGPMSDb();
        }

        public Specialty Get(Guid? id)
        {
            if (id == null || id == Guid.Empty)
            {
                return new Specialty()
                {
                    IsDeleted = false
                };
            }
            else
            {
                return gpmsDb.Specialties
                    .Where(s => s.SpecialtyID == id.Value)
                    .FirstOrDefault();
            }
        }

        public void Add(Specialty specialty)
        {
            if (specialty.SpecialtyID == Guid.Empty)
            {
                specialty.SpecialtyID = Guid.NewGuid();
            }
            specialty.CreateDate = DateTime.Now;
            gpmsDb.Specialties.AddObject(specialty);
            gpmsDb.SaveChanges();
        }

        public void Save(Specialty specialty)
        {
        }
    }
}